<script type="text/javascript">
	$(document).ready(function(){

		   $('#inventory_time').datetimepicker({
	    		  dateFormat: 'yy-mm-dd',
	        	  timeFormat: 'HH:mm:ss',  maxDate: new Date(),}
	    	    );
   	    
 		$("#warehouse_quantity").blur(function(){
			var new_num = $("#warehouse_quantity").val();
			//var old_num = "<?php echo $warehouseInfo['warehouse_quantity']?>";
			//var single_price = "<?php echo $warehouseInfo['single_price']?>";
			//var money = "<?php echo $warehouseInfo['money']?>";
			//var cost = "<?php echo $warehouseInfo['cost']?>";
			//var new_te = $("#transportation_expense").val();
			//var old_te = "<?php echo $warehouseInfo['transportation_expense']?>";
			//var single_money = money/old_num;
			//var single_cost = (cost-old_te)/old_num;
			//var new_money = new_num*single_money;
			//var new_cost = new_num*single_cost;
			var single_price = $("#single_price").val();
			var new_num = $("#warehouse_quantity").val();
			var new_te = $("#transportation_expense").val();
			var new_money = single_price*new_num;
			$("#money").val(new_money.toFixed(2));
			$("#cost").val(parseFloat(new_money)+parseFloat(new_te));
			//cal_cost_money();
 		});

 		$("#single_price").blur(function(){
			var new_num = $("#warehouse_quantity").val();
		  var single_price = $("#single_price").val();
			var te = $("#transportation_expense").val();
			$("#money").val(new_num*single_price);
			$("#cost").val(parseFloat(new_num*single_price)+parseFloat(te));
		});

 		$("#transportation_expense").blur(function(){
			var new_num = $("#warehouse_quantity").val();
		  var single_price = $("#single_price").val();
			$("#cost").val(parseFloat(new_num*single_price)+parseFloat($(this).val()));

		});


 		$("#single_price").change(function(){
 			cal_cost_money();
 		});

		$(".supplierform").Validform({
	        tiptype:2,
	        ajaxPost:true,
			callback:function(data){
				if(data.status=='y'){
					$("input[name='re_quantity']").val($("input[name='warehouse_quantity']").val());
					}
				setTimeout(function(){
					$.Hidemsg(); //公用方法关闭信息提示框;显示方法是$.Showmsg("message goes here.");
				},3000);
			}
		});


	});
</script>
<div class="row">
  <div class="span6">
      <form class="supplierform" method="post" action="<?php  echo URL::base() ?>inventory/report/in_edit_to/">
          <input type="hidden" name="id" value="<?php echo $warehouseInfo['id']?>">
			
          <table class="table ">
              <tr>
                  <td width="30">*</td>
                  <td width="120">选择仓库：</td>
                  <td>
                      <select id='warehouseid' name='warehouseid'>
                          <?php foreach ($warehouse as $id => $name) { ?>
                              <option value="<?php echo $id ?>"><?php echo $name ?></option>
                          <?php } ?>
                      </select>
                  </td>
                  <td></td>
              </tr>
              <tr>
                  <td width="30">*</td>
                  <td width="120">选择主体：</td>
                  <td>
                      <select id='enterprise_dominant' name='enterprise_dominant'>
                          <option value="0">--请选择--</option>
                          <?php foreach ($enterprise_dominants as $id => $name) { ?>
                              <option value="<?php echo $id ?>"><?php echo $name ?></option>
                          <?php } ?>
                      </select>
                  </td>
                  <td></td>
              </tr>
              <tr>
                  <td>*</td>
                  <td>选择入库原因：</td>
                  <td><select id='type' name='type'><?php foreach($status as $st): ?><option value="<?php echo $st['number']?>" <?php if($st['number']==$warehouse['type']) echo 'selected'; ?>><?php echo $st['value']?></option><?php endforeach;?></select></td>
                  <td></td>
              </tr>
              <tr>
                  <td>*</td>
                  <td>SKU：</td>
                  <td><input type="text" value="<?php echo $warehouseInfo['sku']?>" name="sku" class="inputxt"
						datatype="*"
						sucmsg="SKU验证通过" errormsg="输入的SKU有误" readonly="readonly"  /></td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td class="need" style="width: 10px;">*</td>
                  <td style="width: 70px;">供应商：</td>
                  <td style="width: 205px;"><input type="text" value="<?php echo Basic::getnameByid($warehouseInfo['supplier_id'])?>" name="supplier_id" class="inputxt" datatype="*" readonly="readonly" />
                  </td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td>*</td>
                  <td>中文名称：</td>
                  <td><input type="text" value="<?php echo $warehouseInfo['sku_name']?>" name="sku_name" class="inputxt" datatype="*" readonly="readonly" /></td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td>*</td>
                  <td>储位：</td>
                  <td><input type="text" value="<?php echo $warehouseInfo['storage_position']?>" name="storage_position" class="inputxt" readonly="readonly" /></td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td>*</td>
                  <td>数量：</td>
                  <td><input type="text" id="warehouse_quantity" value="<?php echo $warehouseInfo['warehouse_quantity']?>" name="warehouse_quantity" class="inputxt" datatype="/^[1-9](\d+)?$/" errormsg="数量只能为正整数" />
                      <input type="hidden" value="<?php echo $warehouseInfo['warehouse_quantity']?>" name="re_quantity"/></td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td>*</td>
                  <td>单价：</td>
                  <td><input type="text"   value="<?php echo round($warehouseInfo['single_price'],2)?>" id='single_price' name="single_price" /><input type='text' id='display_price' style='display:none'></td>
                  <td></td>
              </tr>
              <tr>
                  <td class="need">*</td>
                  <td>金额：</td>
                  <td><input type="text" value="<?php echo $warehouseInfo['money']?>" id='money' name="money" readonly="readonly"/></td>
                  <td></td>
              </tr>
              <tr>
                  <td class="need">*</td>
                  <td>成本：</td>
                  <td><input type="text"  value="<?php echo $warehouseInfo['cost']?>"  id='cost' name="cost" readonly="readonly"/></td>
                  <td></td>
              </tr>
              <tr>
                  <td class="need">*</td>
                  <td>运费：</td>
                  <td><input type="text" value="<?php echo $warehouseInfo['transportation_expense']?>" id='transportation_expense' name="transportation_expense" class="inputxt" datatype="/^(\d+)(\.\d+)?$/" errormsg="运费只能为正数字" /></td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td class="need"></td>
                  <td>备注：</td>
                  <td><input type="text" value="<?php echo $warehouseInfo['remark']?>" value="" name="remark" class="inputxt" /></td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td class="need">*</td>
                  <td> 入库时间：</td>
                  <td><input type="text"  value="<?php echo $warehouseInfo['warehouse_date']?>" value="" name="warehouse_date" class="inputxt"  id='inventory_time'  datatype="*"  readonly="readonly" /></td>
                  <td><div class="Validform_checktip"></div></td>
              </tr>
              <tr>
                  <td class="need"></td>
                  <td></td>
                  <td colspan="2"><input type="submit" value="提 交" class='btn btn-success' />&nbsp;&nbsp;&nbsp; <input type="reset" value="重 置" class='btn btn-inverse' /></td>
              </tr>
          </table>
      </form>
  </div>
</div>
